-
Notifications
You must be signed in to change notification settings - Fork 5.2k
feat: Display Unlimited for really large spending caps on Permit #29102
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
CLA Signature Action: All authors have signed the CLA. You may need to manually re-run the blocking PR check if it doesn't pass in a few minutes. |
abc6a9a
to
1448df0
Compare
Builds ready [1448df0]
Page Load Metrics (1792 ± 119 ms)
Bundle size diffs
|
truncatedStartChars: 15, | ||
truncatedEndChars: 0, | ||
skipCharacterInEnd: true, | ||
})} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@pedronfigueiredo : not all decoded simulation are Spending Cap
some are even amount that user will receive. Can you plz confirm with if this change is ok for all state change types in decoded simulations.
161d49a
to
e68c588
Compare
Builds ready [e68c588]
Page Load Metrics (1723 ± 81 ms)
Bundle size diffs
|
880f77c
to
41c27cc
Compare
Builds ready [41c27cc]
Page Load Metrics (1815 ± 82 ms)
Bundle size diffs
|
c88c37d
to
359cb29
Compare
Builds ready [359cb29]
Page Load Metrics (1584 ± 33 ms)
Bundle size diffs
|
@@ -10,7 +10,7 @@ import { formatAmount } from '../../../../simulation-details/formatAmount'; | |||
import { useDecodedTransactionData } from '../../hooks/useDecodedTransactionData'; | |||
import { useIsNFT } from './use-is-nft'; | |||
|
|||
const UNLIMITED_THRESHOLD = 10 ** 15; | |||
export const UNLIMITED_THRESHOLD = 10 ** 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It will be better to move the constant to a constants file.
return { | ||
tokenValue: formatAmount('en-US', tokenAmount), | ||
tokenValueMaxPrecision: formatAmountMaxPrecision('en-US', tokenAmount), | ||
shouldShowUnlimitedValue: Number(value) > UNLIMITED_THRESHOLD, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldShowUnlimitedValue
will be Number(value) > UNLIMITED_THRESHOLD && canDisplayValueAsUnlimited
.
We do not gain a lot by memoising it, but if we choose to do so it will be better to memoise whole of Number(value) > UNLIMITED_THRESHOLD && canDisplayValueAsUnlimited
here I think.
359cb29
to
fe64529
Compare
Builds ready [fe64529]
Page Load Metrics (1916 ± 93 ms)
Bundle size diffs
|
fe64529
to
31bd740
Compare
Builds ready [31bd740]
Page Load Metrics (1703 ± 116 ms)
Bundle size diffs
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Could we extend ui/pages/confirmations/components/confirm/info/shared/constants.ts
which also has a single constant in? 😄
@@ -0,0 +1 @@ | |||
export const UNLIMITED_THRESHOLD = 10 ** 15; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Minor, maybe TOKEN_VALUE_UNLIMITED_THRESHOLD
for clarity?
tokenValue: formatAmount('en-US', tokenAmount), | ||
tokenValueMaxPrecision: formatAmountMaxPrecision('en-US', tokenAmount), | ||
shouldShowUnlimitedValue: | ||
canDisplayValueAsUnlimited && Number(value) > UNLIMITED_THRESHOLD, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why do we have to cast, what other type could it be?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
value can be both a number or a string
@@ -56,6 +56,9 @@ type PermitSimulationValueDisplayParams = { | |||
|
|||
/** True if value is being debited to wallet */ | |||
debit?: boolean; | |||
|
|||
/** Wether a large amount can be substituted by "Unlimited" */ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
/** Wether a large amount can be substituted by "Unlimited" */ | |
/** Whether a large amount can be substituted by "Unlimited" */ |
da8f3d1
31bd740
to
da8f3d1
Compare
Builds ready [da8f3d1]
Page Load Metrics (1412 ± 27 ms)
Bundle size diffs
|
Description
Uses
UNLIMITED_THRESHOLD
to determine wether or not to show a permit amount as "Unlimited". Updates unit tests.Related issues
Fixes: https://github.com/MetaMask/MetaMask-planning/issues/3763
Manual testing steps
Screenshots/Recordings
Before
After
Pre-merge author checklist
Pre-merge reviewer checklist